4e6e64160d3ee047e0e21456ebe5eb636c377cdf
3 if( php_sapi_name() != 'cli' ) {
4 echo 'Must be run from the command line.';
8 error_reporting( E_ALL
);
9 define( "MEDIAWIKI", true );
11 set_include_path( get_include_path() . PATH_SEPARATOR
. 'PHPUnit' );
12 set_include_path( get_include_path() . PATH_SEPARATOR
. '..' );
13 require_once( 'PHPUnit.php' );
21 'postgresql' => array(
28 if( file_exists( 'LocalTestSettings.php' ) ) {
29 include( './LocalTestSettings.php' );
40 foreach( $tests as $test ) {
41 require_once( $test . '.php' );
42 $suite = new PHPUnit_TestSuite( $test );
43 $result = PHPUnit
::run( $suite );
44 echo $result->toString();
48 * @param string $serverType
49 * @param array $tables
51 function &buildTestDatabase( $serverType, $tables ) {
52 global $testOptions, $wgDBprefix;
53 $wgDBprefix = 'parsertest';
55 $testOptions[$serverType]['server'],
56 $testOptions[$serverType]['user'],
57 $testOptions[$serverType]['password'],
58 $testOptions[$serverType]['database'] );
60 if (!(strcmp($db->getServerVersion(), '4.1') < 0 and stristr($db->getSoftwareLink(), 'MySQL'))) {
61 # Database that supports CREATE TABLE ... LIKE
62 foreach ($tables as $tbl) {
63 $newTableName = $db->tableName( $tbl );
64 #$tableName = $this->oldTableNames[$tbl];
66 $db->query("CREATE TEMPORARY TABLE $newTableName (LIKE $tableName INCLUDING DEFAULTS)");
69 # Hack for MySQL versions < 4.1, which don't support
70 # "CREATE TABLE ... LIKE". Note that
71 # "CREATE TEMPORARY TABLE ... SELECT * FROM ... LIMIT 0"
72 # would not create the indexes we need....
73 foreach ($tables as $tbl) {
74 $res = $db->query("SHOW CREATE TABLE $tbl");
75 $row = $db->fetchRow($res);
77 $create_tmp = preg_replace('/CREATE TABLE `(.*?)`/', 'CREATE TEMPORARY TABLE `'
78 . $wgDBprefix . '\\1`', $create);
79 if ($create === $create_tmp) {
80 # Couldn't do replacement
81 wfDie( "could not create temporary table $tbl" );
83 $db->query($create_tmp);